package cn.jinzhu.hystrix.service;

import cn.jinzhu.entity.User;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import org.springframework.web.client.RestTemplate;

import java.util.List;
//请求合并第一步
public class UserBatchCommond extends HystrixCommand<List<User>> {
    private  List<Integer> ids;
    private HelloService helloService;

    public UserBatchCommond(List<Integer> ids, HelloService helloService) {
        super(HystrixCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("batchCmd")).
                andCommandKey(HystrixCommandKey.Factory.asKey("batchKey")));
        this.ids = ids;
        this.helloService = helloService;
    }

    @Override
    protected List<User> run() throws Exception {
        return helloService.users(ids);
    }
}
